package com.opeartion.controller;

import com.opeartion.feign.GoodsFeign;
import com.opeartion.pojo.FindGoods;
import com.opeartion.pojo.Goods;
import com.wink.entity.Result;
import com.wink.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @author sanshi
 * @version 1.0
 * @data 2020/6/5-9:34
 */


@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsFeign goodsFeign;

    @GetMapping("/list")
    public Result getAllList(){
        try {
            return new Result(true, StatusCode.ACCESSERROR,"success",goodsFeign.goodsList());
        }catch (Exception e){
            return new Result(false, StatusCode.ERROR,"FALL");
        }
    }

    @PostMapping("/findGoods")
    public  Result goodsList(FindGoods findGoods){
        try {
            System.out.println(findGoods);
            List<Goods> goods = goodsFeign.goodsList(findGoods);
            return new Result(true, StatusCode.ACCESSERROR,"success",goods);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false, StatusCode.ERROR,"FALL");
        }
    }
}
